using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using System.Collections.Generic;
using ESOL.Common.Entity;
using ESOL.Business.Mst;
using System.Data;

namespace ESOL.WinUI.Hr
{
    public partial class frmPrintTemplateCardLoss : DevExpress.XtraReports.UI.XtraReport
    {
        public frmPrintTemplateCardLoss(List<HrAttendanceCardLossEntity> list)
        {
            InitializeComponent();
            DataTable dt = new DataTable();
            dt.Columns.Add("CardLossDate",typeof(DateTime));
            dt.Columns.Add("Reason");
            dt.Columns.Add("ApprovedRemark");
            dt.Columns.Add("DepartmentName");
            dt.Columns.Add("NameCn");
            foreach (HrAttendanceCardLossEntity cardLoss in list)
            {
                DataRow dr = dt.NewRow();
                dr["CardLossDate"] = cardLoss.CardLossDate;
                dr["Reason"] = cardLoss.Reason;
                dr["ApprovedRemark"] = cardLoss.ApprovedRemark;
                MstDepartmentEntity department = MstDepartmentBs.GetMstDepartmentByID(cardLoss.DepartmentId);
                if (department != null)
                {
                    dr["DepartmentName"] = department.DepartmentName;
                }
                MstPersonEntity person = MstPersonBs.GetMstPersonByID(cardLoss.PersonId);
                if (person != null)
                {
                    dr["NameCn"] = person.NameCn;
                }
                dt.Rows.Add(dr);
            }
            this.DataSource = dt;
            txtTime.DataBindings.Add("Text", dt, "CardLossDate");
            txtReason.DataBindings.Add("Text", dt, "Reason");
            txtApprovedRemark.DataBindings.Add("Text", dt, "ApprovedRemark");
            txtDpt.DataBindings.Add("Text", dt, "DepartmentName");
            txtAppPerson.DataBindings.Add("Text", dt, "NameCn");
        }

    }
}
